package com.leapp.sk.ui.activity.album

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.example.mvp.activity.BaseActivityMVP
import com.example.mvp.binder.BaseDataBinder
import com.example.mvp.view.imgselector.ImageSelector
import com.leapp.sk.R
import com.leapp.sk.binder.BaseBinder
import com.leapp.sk.inter.ImageHeadPathInterface
import com.leapp.sk.inter.ImagePathInterface
import com.leapp.sk.util.getResultFile
import com.leapp.sk.viewdelegate.album.EditAlbumDelegate

/**
 * 编辑相册
 * @author  chaohaipeng  on 2018/8/14.
 */
class EditAlbumActivity:BaseActivityMVP<EditAlbumDelegate>(),ImagePathInterface {
    override fun getArrayImagePath(path: List<String>) {
        if (path.size>0){
            viewDelegate.setImage(this,path?.get(0))
        }
    }

    override fun bindEvenListener() {
        viewDelegate.setOnClickListener(View.OnClickListener {
            pickImage()
        },R.id.rl_aea_chose_album_page)

    }
    /**
     * 照片选择
     */
    private fun pickImage() {
        ImageSelector.getInstance()
                .setSelectModel(ImageSelector.MULTI_MODE)
                .setMaxCount(1)
                .setGridColumns(3)
                .setShowCamera(true)
                .startSelect(this)
    }
    override fun initView(p0: Bundle?) {
        viewDelegate.setTitle(resources.getString(R.string.string_edit_album))
    }

    override fun initDate() {
        viewDelegate.initEvent()
    }

    override fun getDelegateClass(): Class<EditAlbumDelegate> {
        return EditAlbumDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return BaseBinder()
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        getResultFile(requestCode, resultCode, data, this, this)
    }
}